package com.example.dingtalklogin.manager.dingtalk;

import feign.RequestInterceptor;
import feign.Retryer;
import feign.codec.ErrorDecoder;
import org.springframework.context.annotation.Bean;

/**
 * 钉钉新版api调用feign的config配置
 * @author xuzhen97
 */
public class DingtalkApiConfig {

    @Bean
    public ErrorDecoder errorDecoder(){
        DingtalkTokenInvalidErrorDecoder errorDecoder = new DingtalkTokenInvalidErrorDecoder();
        return errorDecoder;
    }

    /**
     * 增加feign重试
     * @return
     */
    @Bean
    public Retryer retryer(){
        return new Retryer.Default();
    }

    @Bean
    public RequestInterceptor requestInterceptor(){
        return new ApiTokenInterceptor();
    }
}
